﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QuanLyGiaoVuDAL.Repositories.DatabaseRepositories;
using QuanLyGiaoVuDAL.DTO;

namespace QuanLyGiaoVuService.CommandServices
{
    public class DeTaiCommandService:IDeTaiCommandService
    {
        private IDeTaiRepository _deTaiRepository;
        public DeTaiCommandService(IDeTaiRepository deTaiRepository)
        {
            _deTaiRepository = deTaiRepository;
        }
        public DeTaiDTO InsertDeTai(DeTaiDTO deTaiDTO)
        {
            return _deTaiRepository.InsertDeTai(deTaiDTO);
        }
        public DeTaiDTO UpdateDeTai(DeTaiDTO deTaiDTO) 
        {
            return _deTaiRepository.UpdateDeTai(deTaiDTO);
        }
        public bool DeleteDeTai(Guid maDeTai)
        {
            return _deTaiRepository.DeleteDeTai(maDeTai);
        }

        public void XacNhanDeTai(Guid maDeTai, bool datYeuCau, string lyDoHuy)
        {
            DeTaiDTO detai = _deTaiRepository.GetDeTaiById(maDeTai);
            detai.DaDuyet = true;
            detai.DatYeuCau = datYeuCau;
            if (datYeuCau == false)
                detai.GhiChu = lyDoHuy;
            _deTaiRepository.UpdateDeTai(detai);
        }
    }
}
